{php $bootstrap_type = 3;}
{if empty($_W['isajax'])}
{template 'header'}
<link type="text/css" rel="stylesheet" href="./source/modules/shopping/images/style.css">
<div class="head">
	<a href="javascript:;" onclick="$('.head .order').toggleClass('hide');" class="bn pull-left"><i class="icon-reorder"></i></a>
	<span class="title">商城首页{if $_GPC['pcate']} - {$category[$_GPC['pcate']]['name']}{/if}{if $_GPC['ccate']} - {$children[$_GPC['pcate']][$_GPC['ccate']]['name']}{/if}</span>
	<a href="{php echo $this->createMobileUrl('mycart')}" class="bn pull-right"><i class="icon-shopping-cart"></i><span class="buy-num img-circle" id="carttotal">{$carttotal}</span></a>
	<ul class="unstyled order hide">
		{loop $category $item}
		<li>
			<a href="{php echo $this->createMobileUrl('list', array('pcate' => $item['id']))}" class="bigtype"><i class="icon-folder-open-alt"></i> {$item['name']}</a>
			{loop $children[$item['id']] $child}
			<a href="{php echo $this->createMobileUrl('list', array('ccate' => $child['id']))}" class="smtype"><i class="icon-folder-open-alt"></i> {$child['name']}</a>
			{/loop}
		</li>
		{/loop}
	</ul>
</div>
<div class="shopping-main">
	<div class="left-menu">
		<ul class="unstyled">
			{loop $category $item}
			<li>
				<a href="{php echo $this->createMobileUrl('list', array('pcate' => $item['id']))}" class="bigtype">{$item['name']}</a>
				{loop $children[$item['id']] $child}
				<a href="{php echo $this->createMobileUrl('list', array('ccate' => $child['id']))}" class="smtype">{$child['name']}</a>
				{/loop}
			</li>
			{/loop}
		</ul>
	</div>
	<form action="mobile.php" method="get">
		<input type="hidden" name="act" value="{$_GPC['act']}" />
		<input type="hidden" name="eid" value="{$_GPC['eid']}" />
		<input type="hidden" name="name" value="{$_GPC['name']}" />
		<input type="hidden" name="do" value="{$_GPC['do']}" />
		<input type="hidden" name="weid" value="{$_GPC['weid']}" />
		<div class="input-group">
			<input type="text" class="form-control" name="keyword" value="{$_GPC['keyword']}" placeholder="请输入商品关键字">
			<span class="input-group-btn">
				<button class="btn btn-success" type="submit">搜索</button>
			</span>
		</div>
	</form>
	<div class="list" id="list">
		<div class="list-tips">全部商品 (按销量) - 共<b>{$total}</b>种</div>
{/if}
{loop $list $item}
<div class="list-item img-rounded">
	<div>
		<a href="{php echo $this->createMobileUrl('detail', array('id' => $item['id']))}"><img src="{$_W['attachurl']}{$item['thumb']}"></a>
		<span class="title"><a href="{php echo $this->createMobileUrl('detail', array('id' => $item['id']))}">{$item['title']}</a>{if $item['type'] == '2'}(虚拟){/if}</span>
		<span>{$item['description']}</span>
	</div>
	<span class="sold">
		<span class="soldnum pull-left">已售{$item['sales']}件</span>
		<span class="price pull-right">{$item['marketprice']}元 {if $item['unit']} / {$item['unit']}{/if}</span>
	</span>
	<div class="add-cart" onclick="order.add({$item['id']})"><i class="icon-shopping-cart"></i> 添加到购物车</div>
</div>
{/loop}
{if empty($_W['isajax'])}
	</div>
	<div class="show-more"><a href="javascript:;" onclick="loadPage('{$pindex}', 'list')" class="img-rounded" id="pager">浏览更多商品</a></div>
</div>
<script type="text/javascript">
<!--
	$(function() {
		$(".left-menu").height($(window).height()-105);
	});
	function loadPage(pindex, container) {
		pindex = parseInt(pindex) + 1;
		$.get(location.href, {'page' : pindex}, function(html){
			if (html.indexOf('list-item') > -1) {
				$('#'+container).append(html);
				$('#pager').get(0).onclick = function(){
					loadPage(pindex, container);
				}
			} else {
				$('#pager').html('已经显示全部商品');
			}
		});
	}

	var order = {
		'add' : function(goodsid) {
			var $this = this;
			$this.cart(goodsid, 'add');
		},
		'cart' : function(goodsid, operation) {
			if (!goodsid) {
				alert('请选择商品！');
				return;
			}
			operation = operation ? operation : 'add';
			$.getJSON('{php echo $this->createMobileUrl('updatecart');}', {'op' : operation, 'goodsid' : goodsid}, function(s){
				if (s.message.status) {
					$('#carttotal').css({'width':'50px', 'height':'50px', 'line-height':'50px'}).html(s.message.carttotal).animate({'width':'20px', 'height':'20px', 'line-height':'20px'}, 'slow');
				} else {
					alert(s.message.message);
				}
			});
		}
	};
//-->
</script>
{php $footer_off = 1;}
{template 'footer'}
{template 'footerbar'}
{/if}